package cn.ac.iie.common.util.config;

import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.Properties;

public class Configure {

    String cfgFile;
    Properties proCfg;

    public Configure() throws FileNotFoundException, IOException {
        this.cfgFile = "config.properties";
        System.out.println(this.cfgFile);
        FileInputStream inStream = new FileInputStream(this.cfgFile);
        this.proCfg = new Properties();
        this.proCfg.load(inStream);
    }

    public Configure(String f) throws FileNotFoundException, IOException {
        this.cfgFile = f;
        FileInputStream inStream = new FileInputStream(this.cfgFile);
        this.proCfg = new Properties();
        this.proCfg.load(inStream);
    }

    public String getProperty(String k) {
        return this.proCfg.getProperty(k);
    }

    public int getIntProperty(String k) {
        return Integer.parseInt(this.proCfg.getProperty(k));
    }

    public long getLongProperty(String k) {
        return Long.parseLong(this.proCfg.getProperty(k));
    }

    public Boolean getBooleanProperty(String k) {
        if ("true".equalsIgnoreCase(this.proCfg.getProperty(k))) {
            return Boolean.valueOf(true);
        }
        return Boolean.valueOf(false);
    }
}
